package com.wwj.app.v1;

import com.wwj.core.wawa.entity.WaWa;
import com.wwj.core.wawa.service.IWawaService;
import com.wwj.framework.controller.BaseController;
import com.wwj.framework.utils.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/11/3.
 */
@Controller
@RequestMapping("/v1/wawa")
public class WawaController extends BaseController {

    @Resource
    private IWawaService wawaService;

    @RequestMapping("/{id}")
    @ResponseBody
    public ReturnData wawaInfo(@PathVariable int id) {
        ReturnData returnData = new ReturnData();
        try {
            WaWa wawa = wawaService.findById(id);
            if (wawa == null) {
                returnData.failure("找不到娃娃信息!");
                return returnData;
            }

            returnData.success(wawa);
        } catch (Exception e) {
            logger.error("", e);
            returnData.failure("系统错误,请联系客服");
        }
        return returnData;
    }
}
